package com.fx.attendance.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fx.base.BaseEntity;
import com.fx.domain.system.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @author lijie
 * @since 2020-06-18
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel("人脸表")
@NoArgsConstructor
@AllArgsConstructor
@TableName("face_info")
@Entity
public class FaceInformation extends BaseEntity {

private static final long serialVersionUID=1L;

    @Id
    @NotNull(groups = Update.class)
    @ApiModelProperty(value = "ID", hidden = true)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ApiModelProperty(value = "人脸ID")
    @TableId(value = "guid", type = IdType.UUID)
    private String guid;

    @ApiModelProperty(value = "人脸图像base64密文")
    @Lob
    private byte[] faceContent;

    @JoinColumn(name = "user_id")
    @OneToOne(targetEntity=User.class,fetch= FetchType.LAZY)
    @ApiModelProperty(value = "人脸所属用户编号", hidden = true)
    private User user;

    @ApiModelProperty(value = "有效标志 0 无效 1 有效",example = "0")
    private Integer validFlag;

    @ApiModelProperty(value = "匹配分数阈值（管理员自动可以设置）",example = "0")
    @TableField("standard_score")
    private Integer standardScore;

    public void copy(FaceInformation source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
